<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button class="remove-btn">移除box</button>
  <button class="clone-btn">复制box</button>
  <div class="box">
    <h2>我是标题</h2>
    <p>我是文本,哈哈哈哈哈哈哈</p>
  </div>

  <script>

    var boxEl = document.querySelector(".box")
    var removeBtnEl = document.querySelector(".remove-btn")
    var cloneBtnEl = document.querySelector(".clone-btn")

    removeBtnEl.onclick = function () {
      boxEl.remove()
    }
    var counter = 0
    cloneBtnEl.onclick = function () {
      var newNode = boxEl.cloneNode(true)
      newNode.childNodes[0].textContent = "我也是标题" + counter++
      boxEl.after(newNode)
    }

  </script>
</body>

</html>